home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / wnos5src.zip / NETROM.H < prev    next >
Text File  |  1993-08-09  |  7KB  |  224 lines

  1. #ifndef    _NETROM_H
  2. #define    _NETROM_H
  3.  
  4. #ifndef    _MBUF_H
  5. #include "mbuf.h"
  6. #endif
  7.  
  8. #ifndef    _IFACE_H
  9. #include "iface.h"
  10. #endif
  11.  
  12. #ifndef    _AX25_H
  13. #include "ax25.h"
  14. #endif
  15.  
  16. #ifndef _NR4_H
  17. #include "nr4.h"
  18. #endif
  19.  
  20. /* net/rom support definitions
  21.  * Copyright 1989 by Daniel M. Frank, W9NK.  Permission granted for
  22.  * non-commercial distribution only.
  23.  */
  24.  
  25. #define NR3HLEN        15    /* length of a net/rom level 3 hdr, */
  26. #define NR3DLEN        241    /* max data size in net/rom l3 packet */
  27. #define NR3NODESIG    0xff    /* signature for nodes broadcast */
  28. #define NR3NODEHL    7    /* nodes bc header length */
  29.  
  30. #define NRNUMIFACE    10    /* number of interfaces associated */
  31.                 /* with net/rom network layer      */
  32. #define NRNUMCHAINS    17    /* number of chains in the */
  33.                 /* neighbor and route hash tables */
  34. #define NRRTDESTLEN    21    /* length of destination entry in */
  35.                 /* nodes broadcast */
  36. #define NRDESTPERPACK    11    /* maximum number of destinations per */
  37.                 /* nodes packet */
  38.  
  39. /* NET/ROM protocol numbers */
  40. #define NRPROTO_IP    0x0c
  41.  
  42. /* Internal representation of net/rom network layer header */
  43. struct nr3hdr {
  44.     char source[AXALEN] ;    /* callsign of origin node */
  45.     char dest[AXALEN] ;        /* callsign of destination node */
  46.     unsigned ttl ;                /* time-to-live */
  47. } ;
  48.  
  49. /* Internal representation of net/rom routing broadcast destination */
  50. /* entry */
  51. struct nr3dest {
  52.     char dest[AXALEN] ;        /* destination callsign */
  53.     char alias[AXALEN] ;            /* ident, upper case ASCII, blank-filled */
  54.     char neighbor[AXALEN] ;    /* best-quality neighbor */
  55.     unsigned quality ;        /* quality of route for this neighbor */
  56. } ;
  57.  
  58.  
  59. /* net/rom interface table entry */
  60. struct nriface {
  61.     struct iface *iface ;        /* pointer to ax.25 interface */
  62.     char alias[AXALEN] ;        /* alias for this interface's node */
  63.                                 /* broadcasts */
  64.     char call[AXALEN] ;         /* NREX bke 920716 Call for NETROM-Iface */
  65.     unsigned quality ;            /* net/rom link quality estimate */
  66. } ;
  67.  
  68. /* net/rom neighbor table structure */
  69. struct nrnbr_tab {
  70.     struct nrnbr_tab *next ;    /* doubly linked list pointers */
  71.     struct nrnbr_tab *prev ;
  72.     char call[AXALEN] ;        /* call of neighbor + 2 digis max */
  73.     unsigned iface ;        /* offset of neighbor's port in */
  74.                     /* interface table */
  75.     unsigned refcnt ;        /* how many routes for this neighbor? */
  76. } ;
  77.  
  78. #define    NULLNTAB    (struct nrnbr_tab *)0
  79.  
  80.  
  81. /* A list of these structures is provided for each route table */
  82. /* entry.  They bind a destination to a neighbor node.  If the */
  83. /* list of bindings becomes empty, the route table entry is    */
  84. /* automatically deleted.                                       */
  85.  
  86. struct nr_bind {
  87.     struct nr_bind *next ;        /* doubly linked list */
  88.     struct nr_bind *prev ;
  89.     unsigned quality ;        /* quality estimate */
  90.     unsigned obsocnt ;        /* obsolescence count */
  91.     unsigned flags ;
  92. #define    NRB_PERMANENT    0x01        /* entry never times out */
  93. #define NRB_RECORDED    0x02        /* a "record route" entry */
  94.     struct nrnbr_tab *via ;        /* route goes via this neighbor */
  95. } ;
  96.  
  97. #define    NULLNRBIND    (struct nr_bind *)0
  98.  
  99.  
  100. /* net/rom routing table entry */
  101.  
  102. struct nrroute_tab {
  103.     struct nrroute_tab *next ;    /* doubly linked list pointers */
  104.     struct nrroute_tab *prev ;
  105.     char alias[AXALEN] ;            /* alias of node */
  106.     char call[AXALEN] ;        /* callsign of node */
  107.     unsigned num_routes ;        /* how many routes in bindings list? */
  108.     struct nr_bind *routes ;    /* list of neighbors */
  109.  
  110. } ;
  111.  
  112. #define    NULLNRRTAB    (struct nrroute_tab *)0
  113.  
  114.  
  115. /* The net/rom nodes broadcast filter structure */
  116. struct nrnf_tab {
  117.     struct nrnf_tab *next ;        /* doubly linked list */
  118.     struct nrnf_tab *prev ;
  119.     char neighbor[AXALEN] ;    /* call of neighbor to filter */
  120.     unsigned iface ;        /* filter on this interface */
  121.     unsigned quality;    /* explicit quality of this node */
  122. } ;
  123.  
  124. #define    NULLNRNFTAB    (struct nrnf_tab *)0
  125.  
  126. /* Structure for handling raw NET/ROM user sockets */
  127. struct raw_nr {
  128.     struct raw_nr *prev;
  129.     struct raw_nr *next;
  130.  
  131.     struct mbuf *rcvq;    /* receive queue */
  132.     char protocol;        /* Protocol */
  133. };
  134. #define    NULLRNR    ((struct raw_nr *)0)
  135.  
  136. /* The interface table */
  137. extern struct nriface Nrifaces[NRNUMIFACE] ;
  138.  
  139. /* How many interfaces are in use */
  140. extern unsigned Nr_numiface ;
  141.  
  142. /* The neighbor hash table (hashed on neighbor callsign) */
  143. extern struct nrnbr_tab *Nrnbr_tab[NRNUMCHAINS] ;
  144.  
  145. /* The routes hash table (hashed on destination callsign) */
  146. extern struct nrroute_tab *Nrroute_tab[NRNUMCHAINS] ;
  147.  
  148. /* The nodes broadcast filter table */
  149. extern struct nrnf_tab *Nrnf_tab[NRNUMCHAINS] ;
  150.  
  151. extern char Nr_nodebc[AXALEN];
  152.  
  153. /* filter modes: */
  154. #define    NRNF_NOFILTER    0    /* don't filter */
  155. #define    NRNF_ACCEPT    1    /* accept broadcasts from stations in list */
  156. #define    NRNF_REJECT    2    /* reject broadcasts from stations in list */
  157.  
  158. /* The filter mode */
  159. extern unsigned Nr_nfmode ;
  160.  
  161. /* The time-to-live for net/rom network layer packets */
  162. extern unsigned short Nr_ttl ;
  163.  
  164. /* The obsolescence count initializer */
  165. extern unsigned Obso_init ;
  166.  
  167. /* The threshhold at which routes becoming obsolete are not broadcast */
  168. extern unsigned Obso_minbc ;
  169.  
  170. /* The quality threshhold below which routes in a broadcast will */
  171. /* be ignored */
  172. extern unsigned Nr_autofloor ;
  173.  
  174. /* Whether we want to broadcast the contents of our routing
  175.  * table, or just our own callsign and alias:
  176.  */
  177. extern int Nr_verbose ;
  178.  
  179. /* The maximum number of routes maintained for a destination. */
  180. /* If the list fills up, only the highest quality routes are  */
  181. /* kept.  This limiting is done to avoid possible over-use of */
  182. /* memory for routing tables in closely spaced net/rom networks. */
  183. extern unsigned Nr_maxroutes ;
  184.  
  185. /* The netrom pseudo-interface */
  186. extern struct iface *Nr_iface ;
  187.  
  188. /* Functions */
  189.  
  190. /* In nr3.c: */
  191. void del_rnr __ARGS((struct raw_nr *rpp));
  192. char *find_nralias __ARGS((char *));
  193. struct nrroute_tab *find_nrroute __ARGS((char *));
  194. void nr_bcnodes __ARGS((unsigned ifno,char *dest));
  195. void nr_nodercv __ARGS((struct iface *iface,char *source,struct mbuf *bp));
  196. int nr_nfadd __ARGS((char *, unsigned, unsigned));
  197. int nr_nfdrop __ARGS((char *, unsigned));
  198. void nr_route __ARGS((struct mbuf *bp,struct ax25_cb *iaxp));
  199. int nr_routeadd __ARGS((char *, char *, unsigned,
  200.     unsigned, char *, unsigned, unsigned));
  201. int nr_routedrop __ARGS((char *, char *, unsigned));
  202. int nr_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  203.     int del,int tput,int rel));
  204. void nr_sendraw __ARGS((char *dest,unsigned family,unsigned proto,
  205.     struct mbuf *data));
  206. void nr3output __ARGS((char *dest,struct mbuf *data));
  207. int16 nrhash __ARGS((char *s));
  208. struct raw_nr *raw_nr __ARGS((char));
  209. int ismyNcall __ARGS((char *addr));
  210.  
  211. /* In nrcmd.c: */
  212. void donrdump __ARGS((struct nr4cb *cb));
  213. int doroutedump __ARGS((int argc,char *argv[],void *p));
  214. int dorouteinfo __ARGS((int argc,char *argv[],void *p));
  215. int putalias __ARGS((char *to, char *from,int complain));
  216.  
  217. /* In nrhdr.c: */
  218. struct mbuf *htonnr3 __ARGS((struct nr3hdr *));
  219. struct mbuf *htonnrdest __ARGS((struct nr3dest *));
  220. int ntohnr3 __ARGS((struct nr3hdr *, struct mbuf **));
  221. int ntohnrdest __ARGS((struct nr3dest *ds,struct mbuf **bpp));
  222.  
  223. #endif    /* _NETROM_H */
  224.